package demo2;

import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-08-11
 * Time: 16:43
 */
public class TestDemo4 {

    //创建可以执行延迟任务的线程池
    public static void main(String[] args) {
        ScheduledExecutorService threadPool = Executors.newScheduledThreadPool(5);
        System.out.println("当前加入任务时间 : "+ new Date());
        threadPool.schedule(new Runnable() {
            @Override
            public void run() {
                System.out.println("执行任务时间 : "+ new Date());
            }
        },1,TimeUnit.SECONDS);

    }

}
